#include "EdiflobMessage.h"
#include "Arduino.h"

EdiflobMessage::EdiflobMessage(String command,int index,double r,double g, double b,double t){
  this->_command=command;
  this->_index=index;
  this->_r=r;
  this->_g=g;
  this->_b=b;
  this->_time=t;
  
}
String EdiflobMessage::Serialize(EdiflobMessage msg){

}
EdiflobMessage EdiflobMessage::Deserialize(String msg){
  /*msg.substring(0,3);
  msg.substring(5,9);
  msg.substring(11,14);
  msg.substring(16,19);
  msg.substring(21);
  msg.substring(26);*/
  char strIndex[msg.substring(5,10).length()];
  msg.substring(5,10).toCharArray(strIndex,msg.substring(5,10).length());
  Serial.println(strIndex);
  char strR[msg.substring(11,15).length()];
  msg.substring(11,15).toCharArray(strR,msg.substring(11,15).length());
  Serial.println(strR);
   char strV[msg.substring(16,20).length()];
  msg.substring(16,20).toCharArray(strV,msg.substring(16,20).length());
  Serial.println(strV);
   char strB[msg.substring(21,25).length()];
  msg.substring(21,25).toCharArray(strB,msg.substring(21,25).length());
  Serial.println(strB);
   char strTime[msg.substring(26).length()];
  msg.substring(26).toCharArray(strTime,msg.substring(26).length());
  Serial.println(strTime);
  EdiflobMessage toto(msg.substring(0,3),atoi(strIndex),atof(strR),atof(strV),atof(strB),atof(strTime));
  return toto;
}

String EdiflobMessage::getCommand(){
  return this->_command;
}
int EdiflobMessage::getIndex(){
   return this->_index;
}
double EdiflobMessage::getRed(){
  return this->_r;
}
double EdiflobMessage::getGreen(){
    return this->_g;
}
double EdiflobMessage::getBlue(){
   return this->_b;
}
double EdiflobMessage::getTime(){
  return this->_time;
}
